package com.lvkerry.orderfood.schedule;

import com.lvkerry.orderfood.service.WxApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author Kerry
 */

@Component
public class WxTokenScheduled {

    private Logger logger = LoggerFactory.getLogger(WxTokenScheduled.class);

    private final WxApiService wxApiService;

    @Autowired
    public WxTokenScheduled(WxApiService wxApiService) {
        this.wxApiService = wxApiService;
    }


//    @Scheduled(initialDelay = 5 * 1000, fixedDelay = 7000 * 1000)
    public void scheduledUpdateWxToken() {
        String wxAccessToken = wxApiService.getWxAccessToken();
        logger.info("new weixin token is = {}", wxAccessToken);
    }
}
